package com.haiwen;

import com.haiwen.domain.User;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class LambdaStudy {
    public static void main(String[] args) {
    //使用
    //1.遍历
    List<String> list = Arrays.asList("apple","banana","orange");
    list.forEach(System.out::println);
    //2.排序根据年龄倒序排
        List<User> numList = User.getUserList();
        numList = numList.stream().sorted(Comparator.comparing(User::getAge).reversed()).collect(Collectors.toList());
        System.out.println("排序根据年龄倒序排"+numList);
    //3.过滤  筛选数据中为“a”开头的子字符串
    List<String> list1 = list.stream().filter(s -> s.startsWith("a")).collect(Collectors.toList());
    list1.forEach(System.out::println);
    //4.映射

    //5.规约

    //6.分组

    //7.函数式接口的

    //8.进行线程的创建

    //9.进行Optional的操作

    //10.及逆行stream的流水


    }
}
